<?php
include(getabspath("include/companies_settings.php"));

function DisplayMasterTableInfo_companies($params)
{
	$detailtable=$params["detailtable"];
	$keys=$params["keys"];
	global $conn,$strTableName;
	$xt = new Xtempl();
	$oldTableName=$strTableName;
	$strTableName="companies";

//$strSQL = "SELECT id,   code,   company_name,   category,   address,   city_id,   state_id,   country_id,   port_id,   phone1,   phone2,   fax1,   fax2,   email,   website,   display_name  FROM companies ";

$sqlHead="SELECT id,   code,   company_name,   category,   address,   city_id,   state_id,   country_id,   port_id,   phone1,   phone2,   fax1,   fax2,   email,   website,   display_name";
$sqlFrom="FROM companies";
$sqlWhere="";
$sqlTail="";

$where="";
$mKeys = array();
$showKeys = "";

if($detailtable=="brcs")
{
		$where.= GetFullFieldName("id")."=".make_db_value("id",$keys[1-1]);
	$showKeys .= " Id: ".$keys[1-1];
	$xt->assign('showKeys',$showKeys);
}
	if(!$where)
	{
		$strTableName=$oldTableName;
		return;
	}
	$str = SecuritySQL("Search");
	if(strlen($str))
		$where.=" and ".$str;

	$strWhere=whereAdd($sqlWhere,$where);
	if(strlen($strWhere))
		$strWhere=" where ".$strWhere." ";
	$strSQL= $sqlHead.' '.$sqlFrom.$strWhere.$sqlTail;

//	$strSQL=AddWhere($strSQL,$where);
	LogInfo($strSQL);
	$rs=db_query($strSQL,$conn);
	$data=db_fetch_array($rs);
	if(!$data)
	{
		$strTableName=$oldTableName;
		return;
	}
	$keylink="";
	$keylink.="&key1=".htmlspecialchars(rawurlencode(@$data["id"]));
	


//	id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"id", ""),"field=id".$keylink);
			$xt->assign("id_mastervalue",$value);

//	code - 
			$value="";
				$value = ProcessLargeText(GetData($data,"code", ""),"field=code".$keylink);
			$xt->assign("code_mastervalue",$value);

//	company_name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"company_name", ""),"field=company%5Fname".$keylink);
			$xt->assign("company_name_mastervalue",$value);

//	category - 
			$value="";
				$value = ProcessLargeText(GetData($data,"category", ""),"field=category".$keylink);
			$xt->assign("category_mastervalue",$value);

//	address - 
			$value="";
				$value = ProcessLargeText(GetData($data,"address", ""),"field=address".$keylink);
			$xt->assign("address_mastervalue",$value);

//	city_id - 
			$value="";
				$value = ProcessLargeText(GetData($data,"city_id", ""),"field=city%5Fid".$keylink);
			$xt->assign("city_id_mastervalue",$value);

//	state_id - 
			$value="";
				$value=DisplayLookupWizard("state_id",$data["state_id"],$data,$keylink,MODE_LIST);
			$xt->assign("state_id_mastervalue",$value);

//	country_id - Custom
			$value="";
				$value = GetData($data,"country_id", "Custom");
			$xt->assign("country_id_mastervalue",$value);

//	port_id - Custom
			$value="";
				$value = GetData($data,"port_id", "Custom");
			$xt->assign("port_id_mastervalue",$value);

//	phone1 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"phone1", ""),"field=phone1".$keylink);
			$xt->assign("phone1_mastervalue",$value);

//	phone2 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"phone2", ""),"field=phone2".$keylink);
			$xt->assign("phone2_mastervalue",$value);

//	fax1 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"fax1", ""),"field=fax1".$keylink);
			$xt->assign("fax1_mastervalue",$value);

//	fax2 - 
			$value="";
				$value = ProcessLargeText(GetData($data,"fax2", ""),"field=fax2".$keylink);
			$xt->assign("fax2_mastervalue",$value);

//	email - 
			$value="";
				$value = ProcessLargeText(GetData($data,"email", ""),"field=email".$keylink);
			$xt->assign("email_mastervalue",$value);

//	website - 
			$value="";
				$value = ProcessLargeText(GetData($data,"website", ""),"field=website".$keylink);
			$xt->assign("website_mastervalue",$value);

//	display_name - 
			$value="";
				$value = ProcessLargeText(GetData($data,"display_name", ""),"field=display%5Fname".$keylink);
			$xt->assign("display_name_mastervalue",$value);
	$xt->display("companies_masterlist.htm");
	$strTableName=$oldTableName;
}

?>